import React, { Component, lazy, Suspense } from 'react'
// import About from './About'
// import Home from './Home'
import {Redirect, Route, Switch, NavLink} from 'react-router-dom'

const Home = lazy(()=>import("./Home"))
const About = lazy(()=>import("./About"))

export default class LazyLoad extends Component {
  render() {
    return (
      <div className="App">
        <div className="row">
          <div className="col-xs-2 col-xs-offset-2">
            <div className="list-group">
              <NavLink className="list-group-item " to="/about">about</NavLink>
              <NavLink className="list-group-item " to="/home">home</NavLink>
            </div>
          </div>
          <div className="col-xs-6">
            <div className="panel">
              <div className="panel-body">
                <Suspense fallback={<h1>loading.....</h1>}>
                  <Switch>
                    <Route path="/about" component={About}/>
                    <Route path="/home" component={Home}/>
                    {/* <Redirect to="/about"/> */}
                  </Switch>
                </Suspense>
              </div>
            </div>
          </div>
        </div>
      </div>
    )
  }
}
